package cn.zswltech.gruul.biz.comparator;

import cn.zswltech.gruul.common.entity.DisplayGroupDO;

import java.util.Comparator;

/**
 * 实现排序
 * Author: Jason 2018/8/3
 */
public class DisplayGroupDOComparator implements Comparator {
    @Override
    public int compare(Object arg0, Object arg1) {
        DisplayGroupDO displayGroupDO1 = (DisplayGroupDO) arg0;
        DisplayGroupDO displayGroupDO2 = (DisplayGroupDO) arg1;
        if (displayGroupDO1.getSortNo() == null) {
            return -1;
        } else if (displayGroupDO2.getSortNo() == null) {
            return 1;
        } else {
            int result = displayGroupDO1.getSortNo().compareTo(displayGroupDO2.getSortNo());
            if (result == 0) {
                return displayGroupDO1.getGmtCreate().compareTo(displayGroupDO2.getGmtCreate());
            } else {
                return result;
            }
        }
    }
}
